<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".info").colorbox({width:"80%", height:"70%", iframe:true});
	$(".edit").colorbox({width:"50%", height:"40%", iframe:true});
	$(".bulkedit").colorbox({width:"50%", height:"80%", iframe:true});
	var transaction_id;
	$("#dialog_refund_transaction_id").dialog({autoOpen:false,modal:true});
	$(".addrefund_click").click(function(){
		$("#refund_transaction_id").val($(this).next().val());
		$("#refund_value").val($(this).next().next().val());
		$("#dialog_refund_transaction_id").dialog("open");
		return false;
	});
})
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table" width="100%">
<tr>
	<th width="100">退款日期</th>
	<td>
		<input type="text" name="begin_refund_time" class="datepicker" value="<?=isset($_GET['begin_refund_time']) ? $_GET['begin_refund_time'] : ''?>" /> to
		<input type="text" name="end_refund_time" class="datepicker" value="<?=isset($_GET['end_refund_time']) ? $_GET['end_refund_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>网站/店铺</th>
	<td>
		<select id="shop_id" name="shop_id">
			<option value="">请选择..</option>
			<?foreach ($shop as $k => $sh):?>
			<optgroup label="<?=$k?>">
			<?foreach ($sh as $s):?>
			<option value="<?=$s['id']?>" <?if(isset($_GET['shop_id']) && $_GET['shop_id'] == $s['id']) echo "selected='selected'";?>><?=$s['name']?></option>
			<?endforeach;?>
			</optgroup>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>退款单号</th>
	<td><input type="text" name="number" value="<?=isset($_GET['number']) ? $_GET['number'] : ''?>" /></td>
</tr>
<tr>
	<th>退款交易号</th>
	<td><input type="text" name="refund_transaction_id" value="<?=isset($_GET['refund_transaction_id']) ? $_GET['refund_transaction_id'] : ''?>" /></td>
</tr>
<tr>
	<th>类型</th>
	<td>
		<select name="type">
			<option value="">请选择..</option>
			<option value="1" <?if (isset($_GET['type']) && $_GET['type'] == 1) echo "selected='selected'"?>>+</option>
			<option value="-1" <?if (isset($_GET['type']) && $_GET['type'] == -1) echo "selected='selected'"?>>-</option>
		</select>
	</td>
</tr>
<tr>
	<th>状态</th>
	<td>
		<label><input type="checkbox" name="refund_status[1]" value="1" <?if (isset($_GET['refund_status'][1]))echo "checked='checked'"?> /> 财务未确认</label>
		<label><input type="checkbox" name="refund_status[2]" value="2" <?if (isset($_GET['refund_status'][2]))echo "checked='checked'"?> /> 财务已确认</label>
	</td>
</tr>
<tr>
	<th>发货状态</th>
	<td>
		<label><input type="checkbox" name="shipping_status[0]" value="0" <?if (isset($_GET['shipping_status'][0]))echo "checked='checked'"?> /> 未发</label>
		<label><input type="checkbox" name="shipping_status[1]" value="1" <?if (isset($_GET['shipping_status'][1]))echo "checked='checked'"?> /> 已发</label>
	</td>
</tr>
<tr>
	<th></th>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<table width="100%" class="list_table">
<tr>
	<th width="50">ID</th>
	<th width="100">退款日期</th>
	<th width="130">网站/店铺</th>
	<th width="100">退款单号</th>
	<th width="80">金额</th>
	<th width="60">退款方式</th>
	<th width="140">收款交易号</th>
	<th width="140">退款交易号</th>
	<th width="100">退款原因</th>
	<th width="80">发货状态</th>
	<th>备注</th>
	<th width="120">操作</th>
</tr>
<?foreach ($sales_refund as $sr):?>
<tr>
	<td><?=$sr['id']?></td>
	<td><?=substr($sr['refund_time'], 0, 10)?></td>
	<td><?=$sr['shop_name']?></td>
	<td><a class="info" href="<?=url('Sales::Order/RefundInfo', array('id'=>$sr['id']))?>"><?=$sr['number']?></a></td>
	<td><?=($sr['type']==1)?'+':'-'?><?=$sr['currency_symbol'] . sprintf('%.2f', $sr['refund_amount'])?></td>
	<td><?=Helper_BSS_Normal::getIniOne('sales_order_payment_method', 'value', $sr['refund_method'], 'name')?></td>
	<td><?=isset($sr['receive_transaction_id']) ? $sr['receive_transaction_id'] : ''?></td>
	<td><?=isset($sr['refund_transaction_id']) ? $sr['refund_transaction_id'] : ''?></td>
	<td><?=Helper_BSS_Normal::getIniOne('sales_refund_reason', 'value', $sr['reason'], 'name')?></td>
	<td><?=Helper_BSS_Normal::getIniOne('sales_order_shipping_status', 'value', $sr['shipping_status'], 'name')?></td>
	<td><?=$sr['notes']?></td>
	<td>
		<?if ($sr['status'] == Q::ini('custom_flag/sales_refund_status/new/value')):?>
		<a class="edit" href="<?=url('Sales::Order/RefundEdit', array('id' => $sr['id']))?>">修改</a>
		<a href="<?=url('Sales::Order/RefundDelete', array('id' => $sr['id']))?>" onclick="if( ! confirm('确定删除')) return false;">删除</a>
		<a href="javascript:void(0);" class="addrefund_click">退款</a>
		<?else:?><font color="#aaaaaa">已退</font>
		<?endif;?>
		<input type="hidden" value="<?=$sr['id']?>" />
		<input type="hidden" value="<?=$sr['refund_transaction_id']?>" />
	</td>
</tr>
<?endforeach;?>
</table>
<div id="dialog_refund_transaction_id" title="确认退款">
<form method="post" action="<?=url('Sales::Order/RefundAudit')?>">
<table class="form_table">
<tr>
	<th>退款交易号</th>
	<td>
		<input type="hidden" name="id" id="refund_transaction_id" />
		<input type="text" name="refund_transaction_id" id="refund_value" size="20" />
	</td>
</tr>
<tr>
	<th>退款日期</th>
	<td><input type="text" name="refund_time" class="datepicker" value="<?=date('Y-m-d', CURRENT_TIMESTAMP)?>" /></td>
</tr>
<tr>
	<th></th>
	<td><input type="submit" value="确认" class="button" /></td>
</tr>
</table>
</form>
</div>
<?=$page?>
<a class="bulkedit" href="<?=url('Sales::Order/RefundBulkEdit') ?>"><input type="button" class="button" value="批量修改"/></a>
<?php $this->_endblock(); ?>